package net.loyintean.pearlshell.validation.rule;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.loyintean.pearlshell.validation.IValidRule;
import net.loyintean.pearlshell.validation.IValidRuleConfig;

class StringWithoutChineseValidRuleImpl extends AbstractStringValidRuleImpl
		implements IValidRule {

	StringWithoutChineseValidRuleImpl() {
		super();
	}

	private static final Pattern p = Pattern.compile("[\\u4e00-\\u9fa5]");

	@Override
	public boolean validString(String toValid, IValidRuleConfig config) {

		Matcher m = p.matcher(toValid);

		return !m.find();
	}

	@Override
	public String errorMsg(IValidRuleConfig config) {
		return "不能包含汉字";
	}

}
